package com.simon.stream;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;

public class StreamMain {

    public static final String[] NAMES = new String[]{
            "冯磊杨", "虢方超", "张三", "王五", "赵六", "赵坏正",
            "冯一", "虢方逸", "张雾", "王混合", "赵汉化", "赵士大夫",
    };

    public static void main(String[] args) {
        Random random = new Random();
        List<Person> list = IntStream.rangeClosed(1, 10).mapToObj(index ->
                        Person.builder().name(NAMES[index])
                                .gender(String.valueOf(random.nextInt(1)))
                                .age(random.nextInt(100)).build())
                .toList();
        System.out.println(list);
        List<String> names = list.stream().filter(person -> person.getAge() > 50)
                .map(Person::getName)
                .flatMap(name -> Arrays.stream(name.split("")))
                .toList();

        System.out.println(names);

    }

}
